<?php
namespace App\Dao\version;
use App\Dao\BaseDao;
use App\Models\version\VersionModel;
use function Couchbase\defaultDecoder;
use Illuminate\Support\Facades\DB;
use App\Services\system\SystemLogServices;
use App\Exceptions\ApiException as HOException;
use Hlcreation\Basic\Helper;

class VersionDao extends  BaseDao
{


    public function setModel(){
        return VersionModel::class;
    }


    public function versionList($where){
        $return_list = $this->models::where('type',$where['type'])->orderBy('id','desc')->paginate($where['limit']);

        $res = $this->formatData($return_list);

        return $res;
    }




    //同步添加版本
    public function synchronizationAdd($arr){

        $url = "http://platform.com/platformapi/version/create";
        try {
            $arr_json= json_encode($arr);
            $arr_encode=base64_encode($arr_json);
            $data=Helper::httpPost($url,$arr_encode);

            if(isset($data['code'])){
                if($data['code']==200){
                    return true;
                }else{
                    throw new HOException($data['msg']);
                }
            }else{
                throw new HOException('版本异常');
            }
        } catch (\Exception $e) {
            throw new HOException($e->getMessage());
        }


    }








}
